package com.game.business;

import com.game.business.common.ServerConfig;
import com.game.netty.game.messagedispatcher.DispatchGameMessageService;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;

/**
 * @Author 林道敬
 * @Date 2023-08-12
 * @Description
 **/
@SpringBootApplication(scanBasePackages = { "com.game" })
public class BusinessGameServerMain {
    public static void main(String[] args) {
        ApplicationContext context = SpringApplication.run(BusinessGameServerMain.class,args);
        ServerConfig serverConfig = context.getBean(ServerConfig.class);
        DispatchGameMessageService
                .scanGameMessages(context,serverConfig.getServiceId(),
                        "com.game");
//        GatewayMessageConsumerService gatewayMessageConsumerService =
//                context.getBean(GatewayMessageConsumerService.class);
//        DispatchUserEventService dispatchUserEventService =
//                context.getBean(DispatchUserEventService.class);
//        AsyncPlayerRespository playerRespository =
//                context.getBean(AsyncPlayerRespository.class);
//        DispatchGameMessageService dispatchGameMessageService=
//                context.getBean(DispatchGameMessageService.class);
//        gatewayMessageConsumerService.start((gameChannel) -> {//启动网关消息监听，并初始化GameChannelHandler
//            gameChannel.getChannelPiple().addLast(new GameChannelIdleStateHandler(120,120,100));
//            gameChannel.getChannelPiple().addLast(new GameBusinessMessageDispatchHandler(context,serverConfig,dispatchGameMessageService,dispatchUserEventService, playerRespository));
//            },serverConfig.getServiceId());
    }
}
